package edu.uclmgmu.bacteriosec.domain.data;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

public class ListOfAspectsFamilies {
	private Hashtable<String, AspectFamily> aspectsFamilies;
	
	public ListOfAspectsFamilies() {
		this.aspectsFamilies=new Hashtable<String, AspectFamily>();
	}

	public AspectFamily get(String aspectFamily) {
		return this.aspectsFamilies.get(aspectFamily);
	}

	public void add(AspectFamily aspectFamily) {
		this.aspectsFamilies.put(aspectFamily.getName(), aspectFamily);
	}

	public Enumeration<AspectFamily> getFamilies() {
		return this.aspectsFamilies.elements();
	}

	public void clear() {
		this.aspectsFamilies.clear();
	}

	public void removeMethodCatched(String methodCatched) {
		Enumeration<AspectFamily> aaff=this.aspectsFamilies.elements();
		while (aaff.hasMoreElements()) {
			AspectFamily af=aaff.nextElement();
			if (af.get(methodCatched)!=null)
				af.removeMethodCatched(methodCatched);
		}
	}

	public int getTotalNumberOfCalls() {
		int result=0;
		Enumeration<AspectFamily> aaff=this.aspectsFamilies.elements();
		while (aaff.hasMoreElements()) {
			AspectFamily af=aaff.nextElement();
			result+=af.getNumberOfCalls();
		}
		return result;
	}

	public void loadTestCaseNames(Vector<String> testCaseNames) {
		Enumeration<AspectFamily> aaff=this.aspectsFamilies.elements();
		while (aaff.hasMoreElements()) {
			AspectFamily af=aaff.nextElement();
			af.loadTestCaseNames(testCaseNames);
		}
	}
}
